﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.ExposedReference`1
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine
{
  /// <summary>
  ///   <para>Creates a type whos value is resolvable at runtime.</para>
  /// </summary>
  [UsedByNativeCode(Name = "ExposedReference")]
  [Serializable]
  public struct ExposedReference<T> where T : Object
  {
    [SerializeField]
    public PropertyName exposedName;
    [SerializeField]
    public Object defaultValue;

    public T Resolve(IExposedPropertyTable resolver)
    {
      if (resolver != null)
      {
        bool idValid;
        Object referenceValue = resolver.GetReferenceValue(this.exposedName, out idValid);
        if (idValid)
          return referenceValue as T;
      }
      return this.defaultValue as T;
    }
  }
}
